from flask import Flask
from flask import request
import sqlite3
import StaticSQL


app = Flask(__name__)


def write_log(log: dict):
    id_key = "UUID"
    if id_key in dict:
        uuid = dict[id_key]
        file_name = uuid + ".log"


@app.route("/", methods=["GET", "POST"])
def index():
    for item in request.form:
        print(item)
        if isinstance(item, dict):
            write_log(item)
        # try:
        #     res = json.loads(item)
        # except Exception as e:
        #     print(item)
        # else:
        #     print(res)
    return "Welcome! This is the home page.\n"

def database_operation():
    con = sqlite3.connect("testDB.db")
    cursor = con.cursor()
    try:
        cursor.execute(StaticSQL.createTable)
    except Exception as e:
        print(e)


if __name__ == '__main__':
    app.debug = True
    app.run(host="0.0.0.0")
